class Solution {
public:
    int mySqrt(int x) {
        if(x==1) return x;
        int l=0,r=x;
        while(r-l>1)
        {
            int mid=l+r>>1;
            if((long long)mid*mid>x) r=mid;
            else l=mid;
        }
        return l;
    }
};
